package dto

import (
	"gitee.com/zhoulvvv/my_go_gateway/public"
	"github.com/gin-gonic/gin"
	"time"
)

type AppListInput struct {
	Info     string `json:"info" form:"info" comment:"关键词搜索" example:"" validate:""`                    // 关键词搜索
	PageNo   int    `json:"page_no" form:"page_no" comment:"页数" example:"1" validate:"required"`        // 页数
	PageSize int    `json:"page_size" form:"page_size" comment:"每页数量" example:"20" validate:"required"` // 每页数量
}

type AppListItemOutput struct {
	ID        int64     `json:"id"`
	AppID     string    `json:"app_id" description:"租户id	"`
	Name      string    `json:"name" description:"租户名称"`
	Secret    string    `json:"secret" description:"密钥"`
	WhiteIPS  string    `json:"white_ips"  description:"ip白名单，支持前缀匹配"`
	Qpd       int64     `json:"qpd"  description:"日请求量限制"`
	Qps       int64     `json:"qps"  description:"每秒请求量限制"`
	RealQpd   int64     `json:"real_qpd" description:"日请求量限制"`
	RealQps   int64     `json:"real_qps" description:"每秒请求量限制"`
	UpdatedAt time.Time `json:"create_at"  description:"添加时间"`
	CreatedAt time.Time `json:"update_at"  description:"更新时间"`
	IsDelete  int8      `json:"is_delete"  description:"是否已删除；0：否；1：是"`
}

type AppListOutput struct {
	Total int64               `json:"total" form:"total" comment:"总数"`
	List  []AppListItemOutput `json:"list" form:"list" comment:"租户列表数据"`
}

type AppDetailInput struct {
	Id int `json:"id" form:"id" comment:"租户Id" example:"1" validate:"required"`
}

type AppAddInput struct {
	AppID    string `json:"app_id" form:"app_id" comment:"租户id" validate:"required"`
	Name     string `json:"name" form:"name" comment:"租户名称" validate:"required"`
	Secret   string `json:"secret" form:"secret" comment:"密钥" validate:""`
	WhiteIPS string `json:"white_ips" form:"white_ips" comment:"ip白名单，支持前缀匹配" validate:""`
	Qpd      int64  `json:"qpd"  form:"qpd" comment:"日请求量限制" validate:""`
	Qps      int64  `json:"qps"  form:"qps" comment:"每秒请求量限制" validate:""`
}

type AppUpdateInput struct {
	Id       int64  `json:"id"  form:"id" comment:"租户id" validate:"required"`
	AppID    string `json:"app_id" form:"app_id" comment:"租户id" validate:""`
	Name     string `json:"name" form:"name" comment:"租户名称" validate:"required"`
	Secret   string `json:"secret" form:"secret" comment:"密钥" validate:"required,len=32"`
	WhiteIPS string `json:"white_ips" form:"white_ips" comment:"ip白名单，支持前缀匹配" validate:""`
	Qpd      int64  `json:"qpd"  form:"qpd" comment:"日请求量限制" validate:""`
	Qps      int64  `json:"qps"  form:"qps" comment:"每秒请求量限制" validate:""`
}

type StatisticsOutput struct {
	Today     []int64 `json:"today" form:"today" comment:"今日统计" validate:"required"`
	Yesterday []int64 `json:"yesterday" form:"yesterday" comment:"昨日统计" validate:"required"`
}

func (param *AppUpdateInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *AppAddInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *AppListInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}

func (param *AppDetailInput) BindValidaParam(c *gin.Context) error {
	return public.DefaultGetValidParams(c, param)
}
